home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Re: Incrementing enumerated types
- Date: 02 Feb 1996 18:29:39 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb2112939@qcd.lanl.gov>
- References: <Andy.Law-3101961138310001@pc0734.ri.bbsrc.ac.uk> <4eqoq2$bi5@news.halcyon.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: normanb@halcyon.com's message of Thu, 01 Feb 1996 16:13:20 GMT
-
- In article <4eqoq2$bi5@news.halcyon.com> normanb@halcyon.com (Norm
- Bryar) writes:
- <snip>
- Doubtless not legal because enum values needn't be consecutive.
- enum bleah { error=-1, empty, argle, bargle, targle=4, zargle=8 }.
-
- Use the enum where a programmer must read the code, like in switch
- statements, conditionals, intializations, but cast it to int in the
- for-loop (if you're positive it's values are consecutive, like indices
- into an array).
-
- This is one case where the answer differs in C and C++. In C enums can
- be freely mixed with ints, and they can be incremented or
- decremented.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-